package com.ruoyi.cpi.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.cpi.domain.Region;
import com.ruoyi.cpi.service.IRegionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/region/region")
public class RegionController extends BaseController {
    @Autowired
    private IRegionService regionService;

    /**
     * 查询地区列表
     */
    @PreAuthorize("@ss.hasPermi('region:region:list')")
    @GetMapping("/list")
    public TableDataInfo list(Region region)
    {
        startPage();
        QueryWrapper<Region> queryWrapper=new QueryWrapper<>();
        if (region.getRname()!=null&&!"".equals(region.getRname())){
            queryWrapper.like("rname",region.getRname());
        }
        List<Region> list = regionService.list(queryWrapper);
        return getDataTable(list);
    }
}
